var https = require('https');
var fs = require('fs');
var path=require("path"),
mime=require("./mime").mime;

var options = {
  pfx: fs.readFileSync('gypaygy.com.pfx'),
  passphrase: 'qwertyuioP12'
};

https.createServer(options, function (req, res) {
  showFile('guoyinzaixian.ipa',req, res);
}).listen(2443);


function showFile(filename,req,res){
    fs.readFile(filename,'binary',function(err,file){
        var contentType=mime.lookupExtension(path.extname(filename));
        res.writeHead(200,{
            "Content-Type":contentType,
            "Content-Length":Buffer.byteLength(file,'binary'),
            "Server":"NodeJs("+process.version+")",
            "Content-Disposition":"attachment; filename="+encodeURIComponent(filename)
        });
        res.write(file,"binary");
        res.end();
    })
}


// $HOME/node.js/node-v4.2.4-linux-x64/bin/node download.js 
